//
//  ZYAppointmentCell.m
//  BestLearning
//
//  Created by Ethan on 2017/9/26.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "ZYAppointmentCell.h"
#import "ZYAppointmentModel.h"

@implementation ZYAppointmentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpSuperView];
    }
    
    return self;
    
}


- (void)assignByZYAppointmentModel:(ZYAppointmentModel *)model{
    
    self.nameLabel.text = [NSString stringWithFormat:@"%@",model.element];
    
    NSString *commentCount = [NSString stringWithFormat:@"%@",[model.elementCount[0] valueForKey:@"commentCount"]];
    NSString *totleCommentCount = [NSString stringWithFormat:@"%@",[model.elementCount[0] valueForKey:@"totleCommentCount"]];
    
    float mm = [commentCount doubleValue] /[totleCommentCount doubleValue];
    
    self.pView.progress = mm;
    
    
    
    
}

- (void)setUpSuperView{
    
    self.nameLabel = [UILabel new];
    self.nameLabel.font = [UIFont systemFontOfSize:13];
    self.nameLabel.textColor = ColorRGB(51, 51, 51);
    [self.contentView addSubview:self.nameLabel];
    
    self.nameLabel.text = @"要素一:张宇";
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(8);
        make.top.offset(8);

    }];
    self.appintmentButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.contentView addSubview:self.appintmentButton];
    
//    self.progressView = [[ZYProGressView alloc] initWithFrame:CGRectMake(8, self.nameLabel.origin.y + self.nameLabel.frame.size.height + 38, kScreenWidth - 100, 10)];
    
    self.pView = [UIProgressView new];
  self.pView.progressTintColor= ColorRGB(250, 102, 141);

    self.pView.trackTintColor = ColorRGB(237, 234, 235);
    
    [self.contentView addSubview:self.pView];
    
    
   
    
    [self.pView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.left.offset(10);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(8);
        make.height.offset(10);
        make.width.offset(kScreenWidth - 130);


    }];
    
    [self.appintmentButton setTitle:@"约定" forState:(UIControlStateNormal)];
    [self.appintmentButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    self.appintmentButton.titleLabel.font = [UIFont systemFontOfSize:13];
    [self.appintmentButton setBackgroundImage:[UIImage imageNamed:@"btn_appoint_default"] forState:(UIControlStateNormal)];
    [self.appintmentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-8);
        make.centerY.equalTo(self.pView);
    }];
    
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.mas_equalTo(self.pView).offset(15);
    }];
    
    
}














@end
